import request from '@/utils/request'

// ==================== 通知相关 ====================

/**
 * 获取通知列表
 * @param {Object} params - 查询参数
 * @returns {Promise}
 */
export function getNotificationList(params) {
  return request({
    url: '/api/notifications/',
    method: 'get',
    params
  })
}

/**
 * 获取通知统计信息
 * @returns {Promise}
 */
export function getNotificationStatistics() {
  return request({
    url: '/api/notifications/statistics/',
    method: 'get'
  })
}

/**
 * 标记通知为已读
 * @param {number} notificationId - 通知ID
 * @returns {Promise}
 */
export function markNotificationAsRead(notificationId) {
  return request({
    url: `/api/notifications/${notificationId}/mark_read/`,
    method: 'post'
  })
}

/**
 * 批量标记通知为已读
 * @param {Array} notificationIds - 通知ID数组
 * @returns {Promise}
 */
export function batchMarkAsRead(notificationIds) {
  return request({
    url: '/api/notifications/batch_mark_read/',
    method: 'post',
    data: { notification_ids: notificationIds }
  })
}

/**
 * 全部标记为已读
 * @returns {Promise}
 */
export function markAllAsRead() {
  return request({
    url: '/api/notifications/mark_all_read/',
    method: 'post'
  })
}

/**
 * 删除通知
 * @param {number} notificationId - 通知ID
 * @returns {Promise}
 */
export function deleteNotification(notificationId) {
  return request({
    url: `/api/notifications/${notificationId}/`,
    method: 'delete'
  })
}

/**
 * 批量删除通知
 * @param {Array} notificationIds - 通知ID数组
 * @returns {Promise}
 */
export function batchDeleteNotifications(notificationIds) {
  return request({
    url: '/api/notifications/batch_delete/',
    method: 'post',
    data: { notification_ids: notificationIds }
  })
}

/**
 * 创建通知
 * @param {Object} data - 通知数据
 * @returns {Promise}
 */
export function createNotification(data) {
  return request({
    url: '/api/notifications/',
    method: 'post',
    data
  })
}

/**
 * 创建任务分配通知
 * @param {Object} data - 任务分配数据
 * @returns {Promise}
 */
export function createTaskAssignmentNotification(data) {
  return request({
    url: '/api/notifications/task_assignment/',
    method: 'post',
    data
  })
}

/**
 * 获取用户未读通知数量
 * @returns {Promise}
 */
export function getUnreadCount() {
  return request({
    url: '/api/notifications/unread_count/',
    method: 'get'
  })
}

/**
 * 获取通知详情
 * @param {number} notificationId - 通知ID
 * @returns {Promise}
 */
export function getNotificationDetail(notificationId) {
  return request({
    url: `/api/notifications/${notificationId}/`,
    method: 'get'
  })
}

/**
 * 更新任务状态
 * @param {number} notificationId - 通知ID
 * @param {Object} data - 更新数据
 * @returns {Promise}
 */
export function updateTaskStatus(notificationId, data) {
  return request({
    url: `/api/notifications/${notificationId}/update_task_status/`,
    method: 'post',
    data
  })
}
